//
// Created by root on 6/18/17.
//

#include "../runner.h"

static void test_make_complex() {
    Cell* a = make_integer(global_scheme, 1);
    Cell* b = make_integer(global_scheme, 2);
    Cell* c = make_complex(global_scheme, a, b);
    assert_string_equal(c->_type, COMPLEX_TYPE);
    assert_ptr_equal(car(c), a);
    assert_ptr_equal(cdr(c), b);
}

/**
 * cases for complex div when divided by zero
 * */

static void test_complex_div_when_divided_by_zero() {
    Cell* arg_x = make_complex(global_scheme, make_integer(global_scheme, 1), make_integer(global_scheme, 2));
    Cell* arg_y = make_complex(global_scheme, make_integer(global_scheme, 0), make_integer(global_scheme, 0));
    Cell* r = complex_div(global_scheme, arg_x, arg_y);
    TEST_DIVISION_BY_ZERO(r);
}

int main(int argc, char **argv) {
    const struct CMUnitTest tests[] = {
            cmocka_unit_test(test_make_complex),
            cmocka_unit_test(test_complex_div_when_divided_by_zero),
    };
    return cmocka_run_group_tests(tests, setup_scheme, teardown_scheme);
}
